<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
	<link rel="stylesheet" type="text/css" href="css/loginRegister.css"/>
	<title>iBOOK-登录</title>
</head>
<body id="loginPage">
	<form>
		<p>
			<input type="text" v-model="user.yhm" id="yhm" placeholder="账号"/>
		</p>
		<p>
			<input type="password" v-model="user.pwd" id="pwd" placeholder="密码" maxlength="6"/>
		</p>
		<p>
			<input type="button" value="登录" id="login" @click="doLogin"/>
		</p>
		<p>
			<a href="#" id="left">手机短信登录</a>
			<span id="right">
				<a href="register.html">注册</a> | 
				<a href="#">忘记密码</a> | 
				<a href="index.html">首页</a>
			</span>
		</p>
	</form>
</body>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script>
Vue.createApp({
	data() {
		return {
			user:{
				yhm:'',
				pwd:''
			}
		}
	},
	methods: {
		async doLogin(){
			// 解构: 获取对象中的属性，按同名原则赋值给变量; 比如：将 response.data 属性 赋值给 data
			const {data} = await axios.get('/bms/user',{params: this.user});

			if(data == null || data == ''){
				alert("用户名或密码错误！");
			}else{
				// 登录成功，跳转到主页面
				location = "/bms/index.html";
				//console.log(obj);
			}
		}
	}
}).mount('#loginPage');
</script>
</html>